# 作者: 赵炳森
# 2025年11月10日01时58分19秒
# 2215031808@qq.com
import copy
def use_list_copy():
    a=[1,2,3]
    b=a.copy()
    b[0]=10
    print(a)
    print(b)
def use_copy():
    c=[1,2,3]
    d=copy.copy(c)
    d[0]=10
    print(id(c))
    print(id(d))
    print(c)
    print(d)

def use_copy2():
    a=[1,2]
    b=[3,4]
    c=[a,b]
    d=copy.copy(c)
    print(id(c))
    print(id(d))
    a[0]=10
    print(f'c---{c}')
    print(f'd---{d}')

def use_deepcopy():
    a = [1, 2]
    b = [3, 4]
    c = [a, b]
    d = copy.deepcopy(c)
    print(id(c))
    print(id(d))
    a[0] = 10
    print(f'c---{c}')
    print(f'd---{d}')
    print('-'*50)
    print(id(c[0]),id(c[1]))
    print(id(d[0]),id(d[1]))

class Hero():
    def __init__(self, name, blood) :
        self.name = name
        self.blood = blood
        self.equipment=['鞋子','指环']

def use_copy_own_obj():
    old_hero=Hero('蚂蚁',90)
    new_hero=copy.deepcopy(old_hero)
    new_hero.blood=80
    new_hero.equipment.append('药水')
    print(old_hero.equipment)

if __name__ == '__main__':
    # use_copy()
    # use_copy2()
    # use_deepcopy()
    use_copy_own_obj()